import { watcher } from "@feng3d/watcher";
import { OctahedronGeometry } from "../../thirdparty/three/imports";
import { BufferGeometry3D } from "../core/BufferGeometry3D";

export class OctahedronGeometry3D extends BufferGeometry3D
{
    radius = 1;
    detail = 0;

    get _geometry()
    {
        if (!this.__geometry)
        {
            this.__geometry = new OctahedronGeometry(this.radius, this.detail);
        }

        return this.__geometry;
    }
    declare protected __geometry: OctahedronGeometry;

    constructor()
    {
        super();
        watcher.watchs(this as OctahedronGeometry3D, ["radius", "detail"], this._invalidate, this);
    }

    destroy()
    {
        watcher.unwatchs(this as OctahedronGeometry3D, ["radius", "detail"], this._invalidate, this);
    }
}
